1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
7 <meta name=
"Generator" content=
"Cocoa HTML Writer">
8 <meta name=
"CocoaVersion" content=
"824.48">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
15 span
.Apple-tab-span
{white-space:pre
}
19 <p class=
"p1"><b>Crossplatform
</b></p>
20 <p class=
"p2"><br></p>
21 <p class=
"p3">When extending SuperCollider you may need to take care of cross platform compatibility. This help file tries to make you aware of the issues you need to watch out for.
</p>
22 <p class=
"p2"><br></p>
23 <p class=
"p4"><b>Structure of SuperCollider
</b></p>
24 <p class=
"p2"><br></p>
25 <p class=
"p3">SuperCollider is composed of three or four programs. There is scsynth, sclang, the editor and optionally a GUI server.
</p>
26 <p class=
"p2"><br></p>
27 <p class=
"p3">On OSX most users use the SCapp, which is an editor, including GUI facilities. However, you can also use the GUI server SwingOSC, and may choose to use another editor (such as scel, scvim, or PsyCollider).
</p>
28 <p class=
"p2"><br></p>
29 <p class=
"p3">On Windows most users use PsyCollider or JSCEclipse and use the SwingOSC GUI server. Theoretically it is also possible to run scel or scvim on Windows.
</p>
30 <p class=
"p2"><br></p>
31 <p class=
"p3">On Linux most users use scel or scvim or sced (a gedit frontend) and use the SwingOSC GUI server. But they could also use JSCEclipse or PsyCollider.
</p>
32 <p class=
"p2"><br></p>
33 <p class=
"p5"><br></p>
34 <p class=
"p4"><b>Shortcuts
</b></p>
35 <p class=
"p3">Each editor has its own shortcuts, which are documented in the Shortcuts helpfile.
</p>
36 <p class=
"p5"><br></p>
37 <p class=
"p4"><b>GUI implementation
</b></p>
38 <p class=
"p3">GUI's are made cross platform compatible by using ViewRedirects, or the GUI classes. So instead of using SCWindow, you use Window or GUI.window.new.
</p>
39 <p class=
"p2"><br></p>
40 <p class=
"p3">It may be tempting to create custom GUI objects by subclassing, but this is not good for cross-platform portability. To be truly cross-platform, there should be subclasses for the SC* set of GUI widgets (for the cocoa objects used by SCapp) as well as the JSC* set implemented by SwingOSC. A SCapp user who has not installed SwingOSC cannot use subclasses of the SwingOSC objects, because the parent class is not found in the library. The reverse is true for non-Mac users confronted with subclasses of the cocoa widgets (although this is avoided by placing Mac OSX-specific subclasses into a folder named osx/).
</p>
41 <p class=
"p2"><br></p>
42 <p class=
"p3">Instead, it's recommended to use the Adapter design pattern. Write a new class that creates an instance of the GUI widget whose behavior you want to extend, and include the new behavior in this class. The new class can forward messages to the physical widget where needed, or add new logic between the user's calls and the calls ultimately made to the widget. If the widgets used in the new class are created using the cross-platform view redirect or GUI kit, then it is automatically cross-platform without requiring multiple versions for different platforms.
</p>
43 <p class=
"p2"><br></p>
44 <p class=
"p3">(As a general object-oriented programming rule, subclassing is regarded with some suspicion because the objects' information is not as cleanly encapsulated when a system is built too heavily on subclasses. This is not limited just to GUI cross-platform concerns.)
</p>
45 <p class=
"p2"><br></p>
46 <p class=
"p1">If you want to make a GUI kit specific switch (e.g. in a class), then you should use the following instead, as on non-OSX systems the class CocoaGUI is not in the class library path, and you cannot check for an undefined class:
</p>
47 <p class=
"p2"><br></p>
48 <p class=
"p9"><span class=
"s9">GUI
</span><span class=
"s3">.id;
<span class=
"Apple-tab-span"> </span></span>// returns the current GUI kit implementation id; this is currently either \cocoa or \swing
</p>
49 <p class=
"p2"><br></p>
50 <p class=
"p3"><b>Extension methods added to GUI objects
</b></p>
51 <p class=
"p2"><br></p>
52 <p class=
"p3">At present, extension methods added to, for instance, SCButton do not automatically transfer over to JSCButton. It's necessary to provide the extension for both classes. If the compiler finds an extension for a class that doesn't exist, a warning is printed while compiling the class library, but the interpreter will still function after that. In extensions that are published (e.g. as quarks), it's considered rude to litter the startup output with non-fatal warnings unless there is no other alternative.
</p>
53 <p class=
"p2"><br></p>
54 <p class=
"p3">One approach with quarks is to create a separate quark with the Swing-specific extensions, and include a compatibility test in the quark file.
</p>
55 <p class=
"p2"><br></p>
57 <p class=
"p3"><span class=
"Apple-tab-span"> </span>name:
"quarkname",
</p>
58 <p class=
"p3"><span class=
"Apple-tab-span"> </span>path:
"...",
</p>
59 <p class=
"p3"><span class=
"Apple-tab-span"> </span>... etc...
</p>
60 <p class=
"p3"><span class=
"Apple-tab-span"> </span>isCompatible:
<span class=
"Apple-tab-span"> </span>{ 'SwingOSC'.asClass.notNil }
</p>
62 <p class=
"p2"><br></p>
63 <p class=
"p3">Then the extensions can't be installed on systems without SwingOSC. OSX-specific extensions can be hidden on other platforms by placing them in a folder named osx/. This is not advisable for SwingOSC extensions because these extensions may need to be used on any platform -- it is not valid to restrict them to linux/ or windows/ platform folders.
</p>
64 <p class=
"p5"><br></p>
65 <p class=
"p4"><b>Document implementation
</b></p>
66 <p class=
"p3">Document forwards to an editor dependent class (CocoaDocument for SCapp and ScelDocument for scel). Of these CocoaDocument provides the most functionality, ScelDocument provides a partial set of features. For the other editors there is no Document support yet.
</p>
67 <p class=
"p2"><br></p>
68 <p class=
"p3">The post window is yet another cup of tea. In SCapp it is a Document like any other. In scel it is a separate window which catches stdout (standard output) of sclang. This is the same for the other editors, who either catch the output in a window internal to the editor, or externally (like scvim).
</p>
69 <p class=
"p5"><br></p>
70 <p class=
"p4"><b>Menus
</b></p>
71 <p class=
"p3">Menus are also editor specific, though they can also be added to SwingOSC windows.
</p>
72 <p class=
"p5"><br></p>
73 <p class=
"p4"><b>Help files
</b></p>
74 <p class=
"p3">Help files are generally HTML format. In SCapp they are viewed inside the editor and are regular Documents that are saved as HTML files when they are resaved. In scel they are opened in emacs-w3m in an sclang-minor-mode, so code can be executed from them. For scvim the help files are stripped of their HTML, so they can be opened within scvim as plain text files. Sced opens the help files in Firefox.
</p>
75 <p class=
"p5"><br></p>
76 <p class=
"p4"><b>HID (Human Input Device)
</b></p>
77 <p class=
"p3">HID support is also slightly platform dependent (not editor dependent!). There is a cross platform accessing class called GeneralHID. The only part which is not cross platform yet in that approach is the numbering of the slots, so these cannot be depended upon across platforms.
</p>
78 <p class=
"p2"><br></p>
79 <p class=
"p3">The Windows version of SC should use a python program IxiHID for now with SC to have a partial access to HID devices (only game devices and no output).
</p>
80 <p class=
"p5"><br></p>
81 <p class=
"p4"><b>MouseX, MouseY, MouseButton and KeyState
</b></p>
82 <p class=
"p3">Should work as is on different platforms.
</p>
83 <p class=
"p5"><br></p>
84 <p class=
"p4"><b>WiiMote
</b></p>
85 <p class=
"p3">Has been implemented for both OSX and Linux and have the same interface.
</p>
86 <p class=
"p5"><br></p>
87 <p class=
"p4"><b>Wacom
</b></p>
88 <p class=
"p3">Can be accessed on OSX through a separate interface. On Linux it can be accessed as an HID interface.
</p>
89 <p class=
"p5"><br></p>
90 <p class=
"p4"><b>unixCmd
</b></p>
91 <p class=
"p3">unixCmd works across platforms, but on Windows has to be a DOS command.
</p>
92 <p class=
"p5"><br></p>
93 <p class=
"p4"><b>What to do? Platform specific extensions
</b></p>
94 <p class=
"p3">So, now that you have created a class, what to do if it is not platform independent? Well...
</p>
95 <p class=
"p3">SC implements a scheme to ensure that classes that are only valid for one specific platform are only compiled for that platform. This works by putting a class in a folder (anywhere in the SCClassLibrary or Extensions) named after that platform (osx/windows/linux). Note that this is case sensitive.
</p>
96 <p class=
"p5"><br></p>